package cn.carlos.jiatu.controller;


import cn.carlos.jiatu.api.IJiatuLibService;
import cn.carlos.jiatu.protocol.dto.BookDTO;
import cn.carlos.jiatu.protocol.dto.LibInfoDTO;
import cn.carlos.jiatu.protocol.dto.Payload;
import cn.carlos.jiatu.protocol.vo.BookInfoVO;
import cn.carlos.jiatu.protocol.vo.HoldingVO;
import cn.carlos.jiatu.protocol.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName JiatuLibController
 * @Description TODO
 * @Author Carlos
 * @Date 2023/11/5 10:17
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/jiatu/lib")
@Api(tags = "图书管理")
public class JiatuLibController {
    @Autowired
    IJiatuLibService jiatuLibService;

    @PostMapping("/create")
    @ApiOperation("创建订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name="cardno",value = "读者卡号",dataType = "String",required = true),
            @ApiImplicitParam(name="bookrecno",value = "书目记录号",dataType = "String",required = true)})
    public ResultVO create(@RequestBody Payload payload){
        ResultVO order = jiatuLibService.createOrder(payload);
        return order;
    }

    @GetMapping("/find")
    @ApiOperation("查找书籍")
    @ApiImplicitParams({
            @ApiImplicitParam(name="rows",value = "页面大小",dataType = "int",required = true),
            @ApiImplicitParam(name="page",value = "页码",dataType = "int",required = true),
            @ApiImplicitParam(name="searchWay0",value = "检索方式0，可传title,isbn,author,subject等",dataType = "String"),
            @ApiImplicitParam(name="q0",value = "检索方式0的具体条件",dataType = "String"),
            @ApiImplicitParam(name="logical0",value = "检索方式的关系，OR或者AND",dataType = "String"),
            @ApiImplicitParam(name="searchWay1",value = "检索方式1，可传title,isbn,author,subject等",dataType = "String"),
            @ApiImplicitParam(name="q1",value = "检索方式1的具体条件",dataType = "String"),
            @ApiImplicitParam(name="logical1",value = "检索方式的关系，OR或者AND",dataType = "String"),
            @ApiImplicitParam(name="searchWay2",value = "检索方式0，可传title,isbn,author,subject等",dataType = "String"),
            @ApiImplicitParam(name="q2",value = "检索方式0的具体条件",dataType = "String"),
            @ApiImplicitParam(name="sortWay",value = "排序方式，借阅最多loannum_sort,匹配最高score等",dataType = "String"),
            @ApiImplicitParam(name="sortOrder",value = "排序方式，升序asc,降序desc",dataType = "String"),
            @ApiImplicitParam(name="startPubdate",value = "出版开始时间",dataType = "String"),
            @ApiImplicitParam(name="endPubdate",value = " 出版结束时间",dataType = "String"),
            @ApiImplicitParam(name="hasholding",value = " 是否有馆藏，1.有馆藏",dataType = "int"),
            @ApiImplicitParam(name="booktype",value = " 图书类型，图书，期刊，非书资料，古籍等",dataType = "String"),
            })
    public BookInfoVO find(BookDTO bookDTO){
        BookInfoVO booK = jiatuLibService.findBooK(bookDTO);
        return booK;
    }


    @GetMapping("/libinfo")
    @ApiOperation("馆藏信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="bookRecord",value = "书目记录号",dataType = "String",required = true),
            @ApiImplicitParam(name="limitLibcodes",value = "限制馆代码,传空字符串即可",dataType = "String"),
            @ApiImplicitParam(name="isCluster",value = "传false即可",dataType = "String",required = true)})
    public HoldingVO libinfo(LibInfoDTO lib){
        HoldingVO holdingVO = jiatuLibService.libInfo(lib);
        return holdingVO;
    }
}
